<%@ include file="/WEB-INF/jsp/taglib.jsp" %>

<jsp:useBean id="actionBean" scope="request" type="com.rupertjones.globalcron.web.InfoJobAction" />

<s:layout-render name="/WEB-INF/jsp/layout.jsp" title="Global Cron" subtitle="Job ${actionBean.job.name}">
    <s:layout-component name="body">

    <h1>${actionBean.job.name}</h1>
    <sec:authorize access="hasRole('ROLE_ADMIN')">
        <div style="text-align: right; border:1px; width:100%; padding-bottom:10px;">
            <a title="Edit Job" href="EditJob.action?job.id=${actionBean.job.id}"><img src="resources/edit.gif" border="0"/></a>
        </div>
    </sec:authorize>
    <table class="rounded-corner">
        <tr>
            <td>Host:</td>
            <td>${actionBean.job.hostname}</td>
        </tr>
        <tr>
            <td>Cron:</td>
            <td>${actionBean.job.cron}</td>
        </tr>
        <tr>
            <td>Scheduled:</td>
            <td>${actionBean.job.scheduled}</td>
        </tr>
        <tr>
            <td>TimeZone:</td>
            <td>${actionBean.job.timezone}</td>
        </tr>
        <tr>
            <td>Script:</td>
            <td>${actionBean.job.script}</td>
        </tr>
         <tr>
            <td>Wait after execution (ms):</td>
            <td>${actionBean.job.waitAfter}</td>
        </tr>
        <tr>
            <td>Save Output?:</td>
            <td>${actionBean.job.saveOutput}</td>
        </tr>
        <tr>
            <td>Allow Adhoc Execution ?:</td>
            <td>${actionBean.job.allowAdhocExec}</td>
        </tr>
        <tr>
            <td>Enabled ?:</td>
            <td>${actionBean.job.enabled}</td>
        </tr>
        <tr>
            <td>Next Fire Time (@ Server TimeZone):</td>
            <td>${actionBean.job.nextFireTimeFormatted}</td>
        </tr>
        <tr>
            <td>Next Fire Time (@ ${actionBean.job.timezone}):</td>
            <td>${actionBean.job.nextFireTimeFormattedInExecutionTimezone}</td>
        </tr>
        <tr>
            <td>Time to next fire:</td>
            <td>${actionBean.job.timeToNextFire}</td>
        </tr>
        <tr>
            <td>Last Fire Time (@ Local TimeZone):</td>
            <td>${actionBean.job.lastFireTimeFormatted}</td>
        </tr>
        <tr>
            <td>Last Fire Time (@ ${actionBean.job.timezone}):</td>
            <td>${actionBean.job.lastFireTimeFormattedInExecutionTimezone}</td>
        </tr>
        <tr>
            <td>Time since last fire:</td>
            <td>${actionBean.job.timeSinceLastFire}</td>
        </tr>
        <sec:authorize access="hasRole('ROLE_ADMIN')">
        <c:if test="${actionBean.job.allowAdhocExec}">
            <c:if test="${actionBean.local}">
                <tr>
                    <s:form action="InfoJob.action" beanclass="com.rupertjones.globalcron.web.InfoJobAction">
                    <s:hidden name="job.id"/>
                    <td>Execute this job now</td>
                    <td style="background:red"><input type="image" name="run" src="resources/run.png"/></td>
                    </s:form>
                </tr>
            </c:if>
        </c:if>
        </sec:authorize>
        </table>
        <table>
            <tr>
                <td>
                <h2>Execution Log History</h2>
                <display:table name="actionBean.job.logs" id="line" pagesize="10" requestURI="InfoJob.action" class="rounded-corner">
                    <display:setProperty name="paging.banner.placement" value="bottom"/>
                    <display:column title="When? (@server)" property="lastModified"/>
                    <display:column title="Time Taken (ms)" property="displayTimeTaken"/>
                    <display:column title="Success ?" property="executedNormally"/>
                    <display:column title="Summary">
                        <span title="${line.summary}">${line.limitedSummary}</span>
                    </display:column>
                    <c:if test="${line.hasOutput}">
                        <display:column title="">
                            <a href="InfoJobLog.action?job.id=${actionBean.job.id}&log.id=${line.id}"><img align="right" src="resources/info.png" border="0"></a>
                        </display:column>
                    </c:if>
                </display:table>
                </td>
            </tr>
        </table>

    </s:layout-component>
</s:layout-render>
